package com.example.orderform.contorller;

import com.example.orderform.lmpl.ReceivedLmpl;
import com.example.orderform.server.ReceivedServer;
import com.example.orderform.vo.Order;
import com.example.orderform.vo.Refund;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController

@Api
public class ReceivedContorller {
    @Autowired
    ReceivedServer receivedServer;

    @ApiOperation("待收货查询接口")
    @RequestMapping("/receivedcha")

    public List<Order> receivedcha(@RequestParam("q") int q,
                                   @RequestParam("j") int j,
                                   @RequestParam("userid")int userid){
        List<Order>orderList=receivedServer.receivedchals(q, j,userid);
        if (orderList!=null){
            return orderList;
        }
        return null;
    }

    @ApiOperation("带收货条数")
    @RequestMapping("/taiochas")

    public int taiochas(
            @RequestParam("userid")int userid){
        return  receivedServer.rececha(userid);
    }


    @ApiOperation("订单详情接口")
    @RequestMapping("/orderxq")

    public Order orderxq(@RequestParam("orderid")int orderid){
        System.out.println(orderid);
       Order order= receivedServer.orderxq(orderid);
        return order;
    }

@ApiOperation("退款页面查询")
    @RequestMapping("/receordernumber")

    public List mhselenumber(@RequestParam("ordernumber") String ordernumber)
    {
        System.out.println(ordernumber);
        return receivedServer.receordernumber(ordernumber);
    }

    @ApiOperation("改状态")
    @RequestMapping("/tuikuangs")

    public int tuikuang(@RequestParam("ordernumber") String ordernumber
            ,@RequestParam("reason") String reason)
    {
        receivedServer.tuikuang(ordernumber,reason);
        System.out.println(ordernumber);
        return 1;
    }

    @ApiOperation("退款中订单查询")
    @RequestMapping("/tuikuanchas")

    public List<Order> tuikuancha(@RequestParam("userid") int userid){

        List<Order>orderList=receivedServer.tuikuancha(userid);

        return orderList;
    }

    @ApiOperation("待收货修改状态")
    @RequestMapping("/shuohuogai")

    public int shuohuogai(@RequestParam("orderid") int orderid
           )
    {
        receivedServer.shouhuogai(orderid);
        System.out.println(orderid);
        return 1;
    }

    @ApiOperation("退款新增")
    @RequestMapping("/addrece")
    public int addrece( @RequestParam("ordernumber")String ordernumber,
                            @RequestParam("servicetype")String servicetype,
                            @RequestParam("cargostatus")String cargostatus,
                            @RequestParam("price")String price,
                            @RequestParam("refundreason")String refundreason,
                            @RequestParam("refundinstructions")String refundinstructions,
                            @RequestParam("shoopname")String shoopname,
                            @RequestParam("ordercolor")String ordercolor,
                            @RequestParam("ordersieze")String ordersieze,
                            @RequestParam("picture")String picture) {

        int ss=receivedServer.addrece(ordernumber,servicetype,cargostatus,price,refundreason,refundinstructions,shoopname,ordercolor,ordersieze,picture);
        return ss;
    }


    //收货 卖家同意退款
    @RequestMapping("/updashouhuotongyi")

    public int updashouhuotongyi(@RequestParam("id") int id
    )
    {
        receivedServer.updashouhuotongyi(id);
        return 1;
    }

    @RequestMapping("/updacopytongyi")

    public int updacopytongyi(@RequestParam("orderid") int orderid
    )
    {
        receivedServer.updacopytongyi(orderid);
        return 1;
    }

    //收货 卖家不同意退款
    @RequestMapping("/updashouhuobutongyi")

    public int updashouhuobutongyi(@RequestParam("orderid") int orderid
    )
    {
        receivedServer.updashouhuobutongyi(orderid);
        return 1;
    }


    //后台收货退款成功
    @RequestMapping("/seleshouhuotongyi")

    public List<Refund> seleshouhuotongyi(@RequestParam("userid")int userid){
        System.out.println(userid);
        List<Refund>orderList=receivedServer.seleshouhuotongyi(userid);
        return orderList;
    }


    @RequestMapping("/seleshouhuo")

    public List<Refund> seleshouhuo(@RequestParam("userid")int userid){
        System.out.println(userid);
        List<Refund>orderList=receivedServer.seleshouhuo(userid);
        return orderList;
    }

}
